// import Vue from 'vue'
import config from "../config";
import apiTest from "./api-test";

const request = function(url,param,method='GET'){
	return new Promise((success,fail) => {
		uni.request({
			method:method,
			url:config.base_url + config.api_prefix + url,
			data:param,
			success:success,
			fail:fail,
		})
	})
}


export function post(url,data,options){
		if(config.request_apiTest === true){
			return apiTest("post",url,data)
		}else{
			return request(url,data,'POST');
		}
	}
export function get(url,data,options){
		if(config.request_apiTest === true){
			return apiTest("get",url,data)
		}else{
			return request(url,data,'GET');
		}
	}
